package cn.iocoder.yudao.module.member.dal.mysql.studentEducationalExperience;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.tenant.core.aop.TenantIgnore;
import cn.iocoder.yudao.module.member.controller.admin.studentEducationalExperience.vo.StudentEducationalExperienceExportReqVO;
import cn.iocoder.yudao.module.member.controller.admin.studentEducationalExperience.vo.StudentEducationalExperiencePageReqVO;
import cn.iocoder.yudao.module.member.controller.admin.studentEducationalExperience.vo.StudentEducationalExperienceRespVO;
import cn.iocoder.yudao.module.member.dal.dataobject.studentEducationalExperience.StudentEducationalExperienceDO;
import org.apache.ibatis.annotations.Mapper;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 用户简历教育经历 Mapper
 *
 * @author 管理员
 */
@Mapper
public interface StudentEducationalExperienceMapper extends BaseMapperX<StudentEducationalExperienceDO> {

    default PageResult<StudentEducationalExperienceDO> selectPage(StudentEducationalExperiencePageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<StudentEducationalExperienceDO>()
                .eqIfPresent(StudentEducationalExperienceDO::getStudentId, reqVO.getStudentId())
                .likeIfPresent(StudentEducationalExperienceDO::getSchoolName, reqVO.getSchoolName())
                .eqIfPresent(StudentEducationalExperienceDO::getEducationalBackground, reqVO.getEducationalBackground())
                .betweenIfPresent(StudentEducationalExperienceDO::getFullTime, reqVO.getBeginFullTime(), reqVO.getEndFullTime())
                .eqIfPresent(StudentEducationalExperienceDO::getDiploma, reqVO.getDiploma())
                .eqIfPresent(StudentEducationalExperienceDO::getLevel, reqVO.getLevel())
                .eqIfPresent(StudentEducationalExperienceDO::getGrade, reqVO.getGrade())
                .eqIfPresent(StudentEducationalExperienceDO::getMajor, reqVO.getMajor())
                .eqIfPresent(StudentEducationalExperienceDO::getIsOverseasStudy, reqVO.getIsOverseasStudy())
                .betweenIfPresent(StudentEducationalExperienceDO::getCreateTime, reqVO.getBeginCreateTime(), reqVO.getEndCreateTime())
                .orderByDesc(StudentEducationalExperienceDO::getId));
    }
    @TenantIgnore
    default List<StudentEducationalExperienceDO> selectListByStudentId(Long studentId) {
        return selectList(new LambdaQueryWrapperX<StudentEducationalExperienceDO>()
                .eqIfPresent(StudentEducationalExperienceDO::getStudentId, studentId)
               );
    }

    default List<StudentEducationalExperienceDO> selectList(StudentEducationalExperienceExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<StudentEducationalExperienceDO>()
                .eqIfPresent(StudentEducationalExperienceDO::getStudentId, reqVO.getStudentId())
                .likeIfPresent(StudentEducationalExperienceDO::getSchoolName, reqVO.getSchoolName())
                .eqIfPresent(StudentEducationalExperienceDO::getEducationalBackground, reqVO.getEducationalBackground())
                .betweenIfPresent(StudentEducationalExperienceDO::getFullTime, reqVO.getBeginFullTime(), reqVO.getEndFullTime())
                .eqIfPresent(StudentEducationalExperienceDO::getDiploma, reqVO.getDiploma())
                .eqIfPresent(StudentEducationalExperienceDO::getLevel, reqVO.getLevel())
                .eqIfPresent(StudentEducationalExperienceDO::getGrade, reqVO.getGrade())
                .eqIfPresent(StudentEducationalExperienceDO::getMajor, reqVO.getMajor())
                .eqIfPresent(StudentEducationalExperienceDO::getIsOverseasStudy, reqVO.getIsOverseasStudy())
                .betweenIfPresent(StudentEducationalExperienceDO::getCreateTime, reqVO.getBeginCreateTime(), reqVO.getEndCreateTime())
                .orderByDesc(StudentEducationalExperienceDO::getId));
    }

    default void deleteByStudentId(Long StudentId) {
        Map<String, Object> columnMap = new HashMap<String, Object>();
        columnMap.put("student_id", StudentId);
        deleteByMap(columnMap);
    }

    List<StudentEducationalExperienceRespVO> getStudentEducationalExperienceByStudentId(Long studentId );
}
